#!/usr/bin/env python
# encoding: utf-8


"""
@version: ??
@author: liangliang
@license: Apache Licence 
@contact: liangliangyy@gmail.com
@site: http://www.lylinux.org
@software: PyCharm
@file: serializers.py
@time: 2015/10/2 12:40
"""

from django.forms import widgets
from rest_framework import serializers
from rest_framework import *
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser
from GetApis.models import *


#class DailyWeather()

"""
class DailyField(serializers.Serializer):
     def from_native(self, data):
        if isinstance(data, list):
            return DailyModel(data)
        else:
            pass
            #msg = self.error_messages['invalid']
            #raise ValidationError(msg)

    def to_native(self, obj):
        return obj.tags



class DailyField(serializers.WritableField):
    def from_native(self, data):
        if isinstance(data, list):
            return DailyModel(data)
        else:
            msg = self.error_messages['invalid']
            #raise ValidationError(msg)

    def to_native(self, obj):
        return obj.tags



class WeatherSerializer(serializers.Serializer):
    status=serializers.CharField()
    brf=serializers.CharField()
    txt=serializers.CharField()
    daily_forecast=serializers.ListField(
        date=serializers.CharField(),
    tmpmax=serializers.CharField(),
    tmpmin=serializers.CharField(),
    winddir=serializers.CharField(),
    windsc=serializers.CharField(),
    hum=serializers.CharField(),
    pcpn=serializers.CharField(),
    pop=serializers.CharField(),
    txt_d=serializers.CharField(),
    txt_n=serializers.CharField()
    )

"""


